﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Alert_Form.Component.Alert;
using YXChatFormClient.Dtos;
using YXChatFormClient.Dtos.Buddy;
using YXChatFormClient.Utility;

namespace YXChatFormClient.UserControls
{
    public partial class UC_NewBuddyNotify : UserControl
    {
        public UC_NewBuddyNotify()
        {
            InitializeComponent();
            //设置控件样式
            SetStyle(
                ControlStyles.AllPaintingInWmPaint | //不闪烁
                ControlStyles.OptimizedDoubleBuffer //支持双缓存
                , true);
        }

        public BuddyAccountOutput BuddyAccountOutput { get; set; }
        /// <summary>
        /// 同意添加好友
        /// </summary>
        public delegate void AgreeBuddy(object sender, EventArgs e);
        public AgreeBuddy AgreeBuddyClick;

        private async void btnAgree_Click(object sender, EventArgs e)
        {
            BuddyCreateOrUpdateInput input = new BuddyCreateOrUpdateInput()
            {
                Id = BuddyAccountOutput.RefId,
                IsAgree = true
            };
            HttpHelper http = new HttpHelper();
            await http.PostAsync<bool>(Api.CreateOrUpdateBuddy, input);
            AlertForm.ShowAlert("同意",AlertType.Success);
            AgreeBuddyClick(null,null);
        }

        private void UC_NewBuddyNotify_Load(object sender, EventArgs e)
        {
            this.lbBuddyRemark.Text = BuddyAccountOutput.Account.NickName;
            this.picAvatar.ImageLocation = ImageHelper.GetServerImage(BuddyAccountOutput.Account.Avatar);
        }
    }
}
